//
//  AAAAA.m
//  Pods
//
//  Created by 帅 on 2021/11/3.
//

#import "AAAAA.h"

NSString *const HNNetWorkDEFAULTS_API_MODE_KEY = @"apiMode";

@interface AAAAA ()

@end


@implementation AAAAA


-(NSString *)Accept_Language{
    NSAssert(NO, @"HNNetWorkConfig Accept_Language 不能为空");
    return @"";
}

-(NSString *)AppId{
    NSAssert(NO, @"HNNetWorkConfig AppId 不能为空");
    return @"";
}

-(NSString *)UserAgent{
    NSAssert(NO, @"HNNetWorkConfig UserAgent 不能为空");
    return @"";
}

-(NSString *)UserToken{
    NSAssert(NO, @"HNNetWorkConfig UserToken 不能为空");
    return @"";
}

- (double)longitude{
    return 0;
}

- (double)latitude{
    return 0;
}


-(NSString *)stageURL{
    NSAssert(NO, @"HNNetWorkConfig stageURL 不能为空");
    return @"";
}

-(NSString *)stage2URL{
    NSAssert(NO, @"HNNetWorkConfig stage2URL 不能为空");
    return @"";
}

-(NSString *)devURL{
    NSAssert(NO, @"HNNetWorkConfig devURL 不能为空");
    return @"";
}

-(NSString *)productionURL{
    NSAssert(NO, @"HNNetWorkConfig productionURL 不能为空");
    return @"";
}

- (BOOL)isStage{
    return NO;
}

//切换环境  切换链接
- (void)switchApiConfig:(HNApiMode)apiMode{
    _mode = apiMode;
    [self resetBaseUrlDefault:[self getOriginBaseUrl]];
    [self saveApiMode];
}

- (NSString *)getOriginBaseUrl {
    switch (self.mode) {
        case HNApiModeStage:
            return self.stageURL;
        case HNApiDev:
            return self.devURL;
        case HNApiModeStage2:
            return self.stage2URL;
        default:
            return self.productionURL;
    }
}

- (void)resetBaseUrlDefault:(NSString * _Nonnull)url{
    @synchronized (self) {
        _baseDefaultUrl = url;
    }
}

- (void)initApiMode {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
#ifdef DEBUG
    HNApiMode mode = HNApiModeStage;
#else
    HNApiMode mode = self.isStage ? HNApiModeStage : HNApiModeProduction;
#endif
    
    if ([[defaults dictionaryRepresentation].allKeys containsObject:HNNetWorkDEFAULTS_API_MODE_KEY]) {
        mode = (HNApiMode) [defaults integerForKey:HNNetWorkDEFAULTS_API_MODE_KEY];
    }
    _mode = mode;
}

- (void)saveApiMode {
    [[NSUserDefaults standardUserDefaults] setInteger:self.mode forKey:HNNetWorkDEFAULTS_API_MODE_KEY];
    [[NSUserDefaults standardUserDefaults] synchronize];
}


-(NSMutableArray *)sDimainUrlArray{
    return [NSArray array];
}

@end
